Repository navigation
fix(deps): keep env.jsonc component peers after lane merge, support +^/+~ versions - #10815
davidfirst wants to merge 3 commits into
Conversation
PR Summary by QodoPreserve component peers on lane release and resolve +^/+~ versions
AI Description
Diagram
High-Level Assessment
Files changed (19)
|
Code Review by Qodo
1. Hidden peer updates fail with an error
|
|
Code review by qodo was updated up to the latest commit d48c359 |
| const deps = [ | ||
| ...legacyComponent.dependencies.get(), | ||
| ...legacyComponent.devDependencies.get(), | ||
| ...legacyComponent.peerDependencies.get(), |
There was a problem hiding this comment.
1. Hidden peer updates fail with an error 🐞 Bug ≡ Correctness
updateDependenciesVersionsOfComponent() now iterates legacy peer dependencies, but its package-name lookup uses getDependencies(component), which excludes hidden dependencies by default. When an updated component ID matches a hidden peer, the lookup returns no dependency and the method throws instead of updating it.
Agent Prompt
## Issue description
Updating the ID of a hidden component peer now throws because the peer is in the legacy list but absent from the default dependency-resolver lookup.
## Fix Focus Areas
- scopes/component/snapping/snapping.main.runtime.ts[1411-1425]
## Recommended Fix
Request hidden dependencies when building the lookup used to update legacy dependency IDs, and retain the existing package-name validation.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| this.allPackagesDependencies[key][pkgName] = isPlusVersion(pkgVal) | ||
| ? resolvePlusVersion(pkgVal, this.resolveEnvPeerDepVersion(pkgName, true)) | ||
| : pkgVal; |
There was a problem hiding this comment.
2. A tilde peer setting turns into a caret range 🐞 Bug ≡ Correctness
applyPackageVersion() now calls resolveEnvPeerDepVersion(pkgName, true), which returns the workspace.jsonc value first, and that value is usually a range such as ^18.0.0. resolvePlusVersion() adds the ^/~ prefix only to a plain tag and returns a range unchanged, so +~ (and also the "exact" +) becomes the workspace's ^18.0.0 instead of ~18.2.0 or 18.2.0. The component's saved package peer and its released package.json then get a different range than the one env.jsonc asked for.
Agent Prompt
## Issue description
For a package peer, `+~` and `+` take the workspace.jsonc range as is (for example `^18.0.0`), so the `~` prefix or the exact version that env.jsonc asked for is lost.
## Fix Focus Areas
- scopes/dependencies/dependencies/dependencies-loader/apply-overrides.ts[722-724]
- scopes/dependencies/dependencies/dependencies-loader/apply-overrides.ts[784-795]
- scopes/dependencies/dependency-resolver/plus-version.ts[23-28]
## Recommended Fix
When the resolved value is a range and the placeholder is `+~` or `+`, reduce it to a concrete version before adding the prefix. For example, use `semver.minVersion(range)`, or use the installed concrete version that satisfies the workspace range. Only fall back to the raw range when no concrete version is found. Add unit tests for `+~` with a workspace.jsonc `^` range.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit f4963f0 |
An env.jsonc peer can be a component that is also on the lane. On the lane, the component dependency is a peer with the lane snap. When the lane is released from a bare scope, the snap/tag recalculates the dependency-resolver data from the legacy fields. The legacy fields do not keep component peers. Thus, the peers are removed on main, and each new lane shows them as new dependencies. Also, the released package.json keeps the env.jsonc version, which can be older than the version that is released.
This PR:
toConsumerComponent). The bare-scope snap/tag now keeps them.+^and+~to the+placeholder in env.jsonc (versionandsupportedRange). The placeholder uses the resolved version of the dependency: the snap on a lane, and the new tag after the release (for example,+^gives^1.2.3). A prefix is not added to a snap.bit updateleaves plus entries in env.jsonc alone (it used to crash on+^and replace+with a version), and a package peer with a plussupportedRangefollows the workspace policy.Tests: unit tests for the new helper and the policy validation. An e2e test snaps on a lane, merges, releases from a bare scope, and makes sure that the peer stays and the package.json has
^<new-tag>.